package com.xiaozhichao.nosql.redis;

import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;

import java.util.HashSet;
import java.util.Set;

/**
 * @description: redis demo
 * @author: xiaozhichao
 * @create: 2019-03-29 09:55
 **/
public class Demo {

    JedisCluster jedis = null;

    @Before
    public void connect(){
        Set<HostAndPort> nodes = new HashSet<>();
        nodes.add(new HostAndPort("127.0.0.1",6380));
        nodes.add(new HostAndPort("127.0.0.1",6381));
        nodes.add(new HostAndPort("127.0.0.1",6382));
        nodes.add(new HostAndPort("127.0.0.1",6383));
        nodes.add(new HostAndPort("127.0.0.1",6384));
        nodes.add(new HostAndPort("127.0.0.1",6385));
        jedis = new JedisCluster(nodes);
    }

    @Test
    public void test(){
        jedis.set("testKey1","xiaozhichao");
        String testKey1 = jedis.get("testKey1");
        System.out.println(testKey1);
    }

    public void testBase(){
    }
}
